package one;

public class ClassAndObject2 {
    public static class Student {
        String name;
        int age;
        String Class;

        //构造方法
            //无参构造方法
        Student(){

        }
            //一个参构造方法
        Student(String name){
            this.name = name;
        }
            //三个参构造方法
        Student(String name, int age, String Class) {
            this.name = name;
            this.age = age;
            this.Class = Class;
        }
        //方法
        void say(){
            System.out.println("我叫"+name+",今年"+age+"岁,"+"班级是"+Class);
        }
    }
    public static class test{
        public static void main(String[] args) {
            Student zs = new Student();
            Student ls = new Student("李四");
            Student ww = new Student("王五",18,"一班");
            //若自己不写构造方法，则编译器默认提供一个无参构造方法，添加信息只能一个个添加
            Student zyp = new Student();
            zyp.name = "张逸平";
            zyp.age = 23;

            zs.say();
            ls.say();
            ww.say();
            zyp.say();
        }
    }
}
